package jp.co.hcs.attendancemanagement.login.actionform;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class LoginForm extends ActionForm {

  private static final long serialVersionUID = -1738240904336613775L;

  private String username;

  private String password;

  /**
   * Constructor
   */
  public LoginForm() {
    super();
  }

  /**
   * This is the action called from the Struts framework.
   * 
   * @param mapping The ActionMapping used to select this instance.
   * @param request The HTTP Request we are processing.
   * @return
   */
  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    ActionErrors errors = new ActionErrors();
    if (username == null || username.length() < 1) {
      errors.add("username", new ActionMessage("error.username.required"));
    } else if (password == null || password.length() < 1) {
      errors.add("password", new ActionMessage("error.password.required"));
    }
    return errors;
  }

  /**
   * @return the username
   */
  public String getUsername() {
    return username;
  }

  /**
   * @param username the username to set
   */
  public void setUsername(String username) {
    this.username = username;
  }

  /**
   * @return the password
   */
  public String getPassword() {
    return password;
  }

  /**
   * @param password the password to set
   */
  public void setPassword(String password) {
    this.password = password;
  }

}
